function IC($scope)
{
	$scope.itemsTest = [{name:'first thing',longitude:3, latitude:6, number:3},
					{name:'second thing',longitude:4, latitude:6}];
	$scope.items = [];
	
	selection = {sortBy:'distance', mode:'bounds'};
	bounds = {northWestLat:0, northWestLng:0, southEastLat:10000, southEastLng:10000};
	ownerId = null;
	itemId = null;
	
	$scope.getItems = function(){
		console.log('get(): GetItems'); }
		switch(selection.mode)
		{
			// load object with geographical bounds
			case 'bounds' : url = '/'+BASEPATH+'I/get_bounds/'; var data = bounds; break;
			// load only user item
			case 'user' : url = '/'+BASEPATH+'I/get_items/user/'+ownerId; break;
			// load only one item
			case 'item' : url = '/'+BASEPATH+'I/get_item/'+itemId; break;
		}
		
		$.ajax({
			type: 'POST',
			url: url,
			data: { data : data },
			timeout: 3000,
			success: function(data)
			{
				$scope.items=[];
				setItems(data);
			},
			error: function() { display_alert('connexion problem', '#alert_area', 'error'); console.log('get(): error'); }
		});
		return items;
	}
	
	
	setItems = function(data){
		MM.clearLayer_items();
		$.each(data, function(array) // gives the array containing each item.
		{
			var item = new Item(array); // create an item and give it the array with the content
			items.push(item);
			MM.push(item);
		});
		switch(selection.sortBy)
		{
			case 'distance':
				sortByDistance();
				break;
		}
		console.log('get(): success');
						
	}
	
	sortByDistance = function()
	{
		var center = MM.getCenter();
		for(item in items){
			item.setDistance(center);
		}
		items.sort(function(a,b){ return a.getDistance() - b.getDistance()});
	}
	
	sortByPrice = function()
	{
		items.sort(function(a,b){ return a.getPrice() - b.getPrice()});
	}

	old_onGetItems = function(data)
	{
		// update the array
		// make sure we reset the array
		items = []; 
		// push all items retrieved
		push(data);
		
		switch(page)
		{
			case 'items' :
			// refresh list 
			IMC.displayList(items, sortBy);
			break;
			case 'user' :
			// refresh list 
			IMC.displayList(items, sortBy);
			break;
		}
		
		// display success message
		//display_alert('list updated', '#alert_area', 'success');
		console.log('get(): success');
	}

	old_push = function(data)
	{
		MM.clearLayer_items(); // clear the items layer of the map before adding new items
		$.each(data, function(index, array) // create the array, index count the iterations, array is the content
		{
			var id = array['id'];
			var item = new Item(array); // create an item and give it the array with the content
			items[id] = item; // the associative array "items" collects all the items by id
			//IC.items.push({text:item.name});
			onPush(item);
		});
		
		console.log('pushItem(): success');
	};

	old_onPush = function (item)
	{
		// push the object on the map
		MM.push(item);
	}
	
	old_onGetItem = function(data)
	{	
		// push the item retrieved
		id = data['id'];
		var item = new Item(data); // create an item and give it the array with the content
		// display the tiem
		console.log('displayItem:'+ id);
		
		
		// push the object on the map
		MM.push(item);
		
		IMC.display(item);
	}
	
	
	
}